const Mock = require('mockjs')

module.exports = [
  // 用户登录
  {
    url: '/api/auth/login',
    method: 'post',
    response: ({ body }) => {
      const { username, password, captcha } = body
      if (username === 'admin' && password === 'admin' && captcha) {
        return {
          code: 200,
          msg: '登录成功',
          data: {
            token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIn0.5H4u5VtW96Dd6_5H0Kxg5Jk0T6ZV5H4u5VtW96Dd6_5'
          }
        }
      } else {
        return {
          code: 401,
          msg: '用户名或密码错误'
        }
      }
    }
  },
  
  // 获取用户信息
  {
    url: '/api/user/info',
    method: 'get',
    response: () => {
      return {
        code: 200,
        msg: '操作成功',
        data: {
          id: 1,
          username: 'admin',
          nickname: '管理员',
          avatar: '',
          roles: ['admin'],
          permissions: ['*:*:*']
        }
      }
    }
  },
  
  // 用户登出
  {
    url: '/api/auth/logout',
    method: 'post',
    response: () => {
      return {
        code: 200,
        msg: '退出成功'
      }
    }
  }
]